package org.jeecg.modules.goods.goods.enums;

import lombok.Getter;

/**
 * 字典字段枚举
 * 定义需要进行字典转换的字段及其对应的字典信息
 */
@Getter
public enum DictFieldEnum {

    /**
     * 采购人员 - 用户表
     */
    PROCUREMENT_PERSONNEL("procurementPersonnel", DictTypeEnum.TABLE, "sys_user", "realname", "id"),

    /**
     * 开发人员 - 用户表
     */
    DEVELOPERS("developers", DictTypeEnum.TABLE, "sys_user", "realname", "id"),

    /**
     * 负责人员 - 用户表
     */
    RESPONSIBLE_OFFICER("responsibleOfficer", DictTypeEnum.TABLE, "sys_user", "realname", "id"),

    /**
     * 产品品牌 - 数据字典
     */
    GOODS_BRAND("goodsBrand", DictTypeEnum.DICT, "XFPP", null, null),

    /**
     * 产品分类 - 分类字典
     */
    CATEGORY_ID("categoryId", DictTypeEnum.CATEGORY, null, null, null),

    /**
     * 计价方式 - 数据字典
     */
    VALUATION_METHOD("valuationMethod", DictTypeEnum.DICT, "JJFS", null, null),

    /**
     * 包装 - 数据字典
     */
    PACKAGING("packaging", DictTypeEnum.DICT, "SF", null, null),

    /**
     * 二级分类 - 数据字典
     */
    SECONDARY_CATEGORY("secondaryCategory", DictTypeEnum.DICT, "EJFL", null, null),

    /**
     * 质量 - 数据字典
     */
    QUALITY("quality", DictTypeEnum.DICT, "ZL", null, null),

    /**
     * 材质/细分品牌 - 数据字典
     */
    MATERIAL("material", DictTypeEnum.DICT, "XFPP", null, null),

    /**
     * 适配品牌 - 数据字典
     */
    COMPATIBLE_BRAND("compatibleBrand", DictTypeEnum.DICT, "SPPP", null, null),

    /**
     * 供应情况 - 数据字典
     */
    SUPPLY_SITUATION("supplySituation", DictTypeEnum.DICT, "GYQK", null, null),

    /**
     * 性质 - 数据字典
     */
    NATURE("nature", DictTypeEnum.DICT, "XZ", null, null),

    /**
     * 含电或含液 - 数据字典
     */
    ELECTRICAL_LIQUID("electricalLiquid", DictTypeEnum.DICT, "XZ", null, null),

    /**
     * 标签型号 - 数据字典
     */
    LABEL_MODEL("labelModel", DictTypeEnum.DICT, "BQXH", null, null),

    /**
     * 标签质量 - 数据字典
     */
    LABEL_QUALITY("labelQuality", DictTypeEnum.DICT, "BQZL", null, null),

    /**
     * 仓库信息 - 表字典
     */
    WAREHOUSE_INFO("warehouseInfo", DictTypeEnum.TABLE, "sd_warehouse", "warehouse_name", "id"),

    /**
     * 货位信息 - 表字典
     */
    STORAGE_LOCATION("storageLocation", DictTypeEnum.TABLE, "wh_location", "location_name", "id"),

    /**
     * 供货商信息 - 表字典
     */
    SUPPLIER_INFO("supplierInfo", DictTypeEnum.TABLE, "wh_supplier", "name", "id");

    /**
     * 字段名
     */
    private final String fieldName;

    /**
     * 字典类型
     */
    private final DictTypeEnum dictType;

    /**
     * 表名（表字典时使用）
     */
    private final String tableName;

    /**
     * 显示字段（表字典时使用）
     */
    private final String textField;

    /**
     * 值字段（表字典时使用）
     */
    private final String valueField;

    DictFieldEnum(String fieldName, DictTypeEnum dictType, String tableName, String textField, String valueField) {
        this.fieldName = fieldName;
        this.dictType = dictType;
        this.tableName = tableName;
        this.textField = textField;
        this.valueField = valueField;
    }

    /**
     * 根据字段名获取枚举
     *
     * @param fieldName 字段名
     * @return 对应的枚举值
     */
    public static DictFieldEnum fromFieldName(String fieldName) {
        for (DictFieldEnum dictField : DictFieldEnum.values()) {
            if (dictField.getFieldName().equals(fieldName)) {
                return dictField;
            }
        }
        return null;
    }
}
